<div class='accordion'>
	<h3><a href="#">Gestion</a></h3>
	<div id='news_main'>
		<div id='news_liste' class='ui-corner-all ui-widget-content' style='padding-top: 5px; padding-bottom: 5px;'>
			<table id='newsliste' cellspacing='0' cellpadding='1' style='width: 100%; border-top: 1px solid #000000;'>
				<? $res=$sql->request("select * from ".CFG_MYSQL_PREFIX."news order by ts desc,id desc");
				$i=0;
				foreach($res as $var){
					$news= new news($var); ?>
				<tr>
					<td id='N<? echo $news->id; ?>' class='ui-state-default' onmouseover='$(this).addClass("ui-state-hover");' onmouseout='$(this).removeClass("ui-state-hover");' style='width: 10px; padding-left: 2px; border-width: 0px; border-bottom: 1px solid #000000; border-right: 1px solid #AAAAAA; cursor: pointer;' onclick="$('#dialog').attr('idNEws',$(this).attr('id')); open_dialog('Supprimer une news', 'Etes-vous sur de vouloir supprimer cette news?', { 'Non': function() { $(this).dialog('close'); }, 'Oui': function() { document.getElementById('formNewsSupprimerNews'+$(this).attr('idNews')).submit(); $(this).dialog('close'); open_loading(); } });">
						<span class="ui-icon ui-icon-circle-close tooltip" title='Supprimer cette news'></span>
						<form name='formNewsSupprimerNewsN<? echo $news->id; ?>' id='formNewsSupprimerNewsN<? echo $news->id; ?>' action='admin?confmodule=news' method='post'>
							<input type='hidden' name='id' value='<? echo $news->id; ?>' />
							<input type='hidden' name='action' value='supprimer_news' />
						</form>
					</td>
					<td class='ui-state-default' onmouseover='$(this).addClass("ui-state-hover");' onmouseout='$(this).removeClass("ui-state-hover");' style='padding-left: 5px; cursor: pointer; border-width: 0px 0px 1px 0px;' onclick="window.open('admin?confmodule=news&editNews=<? echo $news->id; ?>','_self');"><? $titre=$news->get_titre(); if(strlen($titre)<23) echo $titre; else echo substr($titre,0,23)."[...]"; ?></td>
				</tr>
				<? $i++; } ?>
			</table>
			<br />
			<div class='align-center'><a href="#" onclick="window.open('admin?confmodule=news','_self');;" class="a-button ui-state-default ui-corner-all"><span class="ui-icon ui-icon-circle-plus"></span>Nouvelle news</a></div>
			<br />
		</div>
		<? if(isset($_REQUEST["editNews"])){
			$var=$sql->request_single("select * from ".CFG_MYSQL_PREFIX."news where id=".$_REQUEST["editNews"]);
			$news=new news($var); ?>
		<div class='ui-widget-header ui-corner-all title2'>Modifier une news</div>
		<div id='news_content' class='ui-corner-all ui-widget-content'>
			<form name='formAdminEditNews' method='post' action=''>
				<table style='width: 100%;'>
					<tr>
						<td>Titre : </td>
						<td><input type='text' name='titre'  value="<? echo $news->get_titre(); ?>" style='width: 630px;' /></td>
					</tr>
					<tr>
						<td>Date : </td>
						<td><input type='text' name='date' class='datePicker'  value='<? echo date("d/m/Y",$news->ts); ?>' /></td>
					</tr>
					<tr>
						<td>Auteur : </td>
						<td><input type='text' name='auteur' value='<? echo $news->auteur; ?>' /></td>
					</tr>
					<tr>
						<td style='vertical-align: top;'>Texte : </td>
						<td><textarea name="texte" id="texte"><? echo $news->get_texte(); ?></textarea></td>
					</tr>
				</table>
				<br />
				<div class='align-center'><a href="#" onclick="if(document.getElementById('texte')){ open_loading();  document.formAdminEditNews.submit(); }else alert('test');" class="a-button ui-state-default ui-corner-all"><span class="ui-icon ui-icon-newwin"></span>Modifier</a></div>
				<br />
				<input type="hidden" name='id' value='<? echo $news->id; ?>' />
				<input type="hidden" name='action' value='editer_news' />
			</form>
		</div>
		<? }else{ ?>
		<div class='ui-widget-header ui-corner-all title2'>Ajouter une news</div>
		<div id='news_content' class='ui-corner-all ui-widget-content'>
			<form name='formAdminAddNews' method='post' action=''>
				<table style='width: 100%;'>
					<tr>
						<td>Titre : </td>
						<td><input type='text' name='titre' style='width: 630px;' /></td>
					</tr>
					<tr>
						<td>Date : </td>
						<td><input type='text' name='date' class='datePicker' value='<? echo date("d/m/Y"); ?>' /></td>
					</tr>
					<tr>
						<td>Auteur : </td>
						<td><input type='text' name='auteur' value='<? echo $USER->nom; ?>' /></td>
					</tr>
					<tr>
						<td style='vertical-align: top;'>Texte : </td>
						<td><textarea name="texte" id="texte"></textarea></td>
					</tr>
				</table>
				<br />
				<div class='align-center'><a href="#" onclick="if(document.getElementById('texte')){ open_loading();  document.formAdminAddNews.submit(); }else alert('test');" class="a-button ui-state-default ui-corner-all"><span class="ui-icon ui-icon-circle-plus"></span>Ajouter</a></div>
				<br />
				<input type="hidden" name='action' value='ajouter_news' />
			</form>
		</div>
		<? } ?>
	</div>
	<h3><a href="#">Configuration</a></h3>
	<div>
		<form name='formAdminNews' action='' method='post'>
			<table style='width: 100%;' cellspacing='0' cellpadding='2' class='ui-corner-all ui-widget-content'>
				<tr class='tr1'>
					<td style='width: 250px;'>Nombre de news par page</td>
					<td>
						<input type='text' name='cfg_news_par_page' value='<? echo $cfg_params["news_par_page"]; ?>' />
					</td>
				</tr>
				<tr class='tr2'>
					<td>Activer les commentaires</td>
					<td>
						<input type='hidden' name='cfg_news_commentaires' value='0' />
						<input type='checkbox' name='cfg_news_commentaires' value='1' <? if($cfg_params["news_commentaires"]) echo "checked='checked'"; ?> />
					</td>
				</tr>
			</table>
			<br />
			<div class='align-center'><a href="#" onclick='open_loading(); document.formAdminNews.submit();' class="a-button ui-state-default ui-corner-all"><span class="ui-icon ui-icon-disk"></span>Enregistrer</a></div>
			<br />
			<input type='hidden' name='action' value='enregistrer_configuration' />
		</form>
	</div>
</div>